using Unity.VisualScripting;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Load Dictionary")]
    [UnitSurtitle("Dependency Asset")]
    public sealed class LoadSceneDependencyAsset : FrameworkEventUnit<LoadSceneDependencyAssetEventArgs>
    {
        protected override int EventId => LoadSceneDependencyAssetEventArgs.EventId;
        protected override string HookName => UGFHookNames.LoadSceneDependencyAsset;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput SceneAssetName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DependencyAssetName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput LoadedCount
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput TotalCount
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            SceneAssetName = ValueOutput<string>(nameof(SceneAssetName));
            DependencyAssetName = ValueOutput<string>(nameof(DependencyAssetName));
            LoadedCount = ValueOutput<int>(nameof(LoadedCount));
            TotalCount = ValueOutput<int>(nameof(TotalCount));
            UserData = ValueOutput<object>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, LoadSceneDependencyAssetEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(SceneAssetName, args.SceneAssetName);
            flow.SetValue(DependencyAssetName, args.DependencyAssetName);
            flow.SetValue(LoadedCount, args.LoadedCount);
            flow.SetValue(TotalCount, args.TotalCount);
            flow.SetValue(UserData, args.UserData);
        }
    }
}